package cn.wyu.blogrest.service;

import cn.wyu.blogrest.entity.Status;
import cn.wyu.blogrest.repository.StatusRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class StatusService {
    @Autowired
    private StatusRepository statusRepository;

    /**
     * 点赞数+1
     */
    public Status incLikes(int statusId){
        Status status = this.statusRepository.findById(statusId);
        status.setLikes(status.getLikes()+1);
        return this.statusRepository.save(status);
    }
}
